﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Gmantis.Controls
{
    internal class OrderedSetEnumerator : IEnumerator<int>, IDisposable, IEnumerator
    {
        // Fields
        private int _current = -1;
        private OrderedSet _set;

        // Methods
        public OrderedSetEnumerator(OrderedSet set)
        {
            this._set = set;
        }

        public void Dispose()
        {
        }

        public bool MoveNext()
        {
            if ((this._current + 1) < this._set.Count)
            {
                this._current++;
                return true;
            }
            return false;
        }

        public void Reset()
        {
            this._current = -1;
        }

        // Properties
        public int Current
        {
            get
            {
                if (this._current >= 0)
                {
                    return this._set[this._current];
                }
                return -1;
            }
        }

        object IEnumerator.Current
        {
            get
            {
                return this.Current;
            }
        }
    }
}
